#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e7;

ll a[N];

int solve()
{
	int ans=0,n;
	cin>>n;
	while(n)
	{
		if(a[1]>=n)
		{
			if(a[1]==n)	ans++;
			break;
		}
		ll p=lower_bound(a,a+1000000,n)-a;
		if(a[p]==n)
		{
			ans++;
			break;
		}
		p--;
		n-=a[p];
		ans++;
	}
	cout<<ans<<endl;
	
}

int main()
{

	for(ll i=1;i<=1e6;i++)
	{
		a[i]=i*(3*i+1)/2;
	}
	
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}
}
